-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command Plugin for generating the source code #98
Conversation
This seems good to me. To summarise:
In scenario (1), I can see in the screenshot two things that would be nice to improve:
I don't mind deferring that to another PR though. WDYT @czechboy0 @MahdiBM? |
@simonjbeaumont
Good idea but will basically duplicate the logs because we'll need to say Should i go for it? or did you mean something else?
No objections, but can you mention some examples so i know what you exactly have in mind? |
What i do prefer though, is for the Docs part to be deferred to another PR considering this has taken enough time/length 😅 would prefer this to be merged sooner than later, when possible, so i can also start using the main Apple repo in my |
OK, great! Both of these comments pertain to this logging from your screenshot above, so I'll paste the textual version here before continuing to discuss your specific questions:
Personally, I prefer logging to be before an operation, and, looking through the build logs in Xcode for a target I happen to have open I see this pattern. Examples include
When the issue if fixed, I see:
I think it's odd to see big green check marks and lots of I'm not suggesting we go for emojis, but I'd be happy with us finding some terminology that is clear about what's going on, for example:
I'd be happy if it then printed a line explicitly saying whether it was succeeded or failed. IMHO this small amount of "duplicate" logging is a small price to pay for clarity when debugging a failed build. |
@simonjbeaumont This is what i came up with. Please let me know if i can improve any of the sentences. I used the ✅ emoji for a successful code generation because i think it makes long logs like this more skimmable. The |
While I initially hinted at not doing this, I think I agree; it does make it easier to read at a glance so I'm fine with it 👍
Aside from tone, this one in particular isn't informative—why isn't it "configured" and what does it mean for it to be configured? I this case we could have something like: Other than that I'm pleased with how this is looking. @czechboy0 do you have anything to add before we push this over the line? |
@simonjbeaumont i made it non-informative because i suspected @czechboy0 would not like the duplication of "there are no files" messages as he requested some changes about them in the past reviews. Though i think both views are completely valid. It's just a question of if the information is worth the duplication. I'm personally fine with both, maybe slightly leaning towards the current non-informative message. |
OK, that's fair enough, and sorry for missing that historical review context. I'm happy with things the way they are now (subject to the soundness check passing again). |
Honestly i had no idea what some of the warnings were requesting: ** ✅ Found no unacceptable language.
** Running /code/scripts/check-license-headers.sh...
** ERROR: Unsupported file extension for file (exclude or update this script): Plugins/OpenAPIGenerator/PluginsShared
** Running /code/scripts/run-swift-format.sh...
Plugins/PluginsShared/PluginUtils.swift:4:92: warning: [UseEarlyExits] replace the `if/else` block with a `guard` statement containing the early exit
Plugins/PluginsShared/PluginUtils.swift:4:92: warning: [UseEarlyExits] replace the `if/else` block with a `guard` statement containing the early exit
/code/Package.swift:173:10: warning: [TrailingComma] add trailing comma to the last element in multiline collection literal
Package.swift:164:1: warning: [LineLength] line is too long
Plugins/PluginsShared/PluginError.swift:14:1: warning: [LineLength] line is too long
Plugins/PluginsShared/PluginError.swift:21:1: warning: [LineLength] line is too long
Plugins/PluginsShared/PluginError.swift:97:1: warning: [LineLength] line is too long
Plugins/PluginsShared/PluginError.swift:99:1: warning: [LineLength] line is too long
Plugins/PluginsShared/PluginError.swift:104:1: warning: [LineLength] line is too long
Plugins/PluginsShared/PluginError.swift:106:1: warning: [LineLength] line is too long
Plugins/PluginsShared/PluginUtils.swift:4:1: warning: [LineLength] line is too long
Plugins/OpenAPIGeneratorCommand/plugin.swift:58:1: warning: [LineLength] line is too long
Plugins/OpenAPIGeneratorCommand/plugin.swift:59:1: warning: [LineLength] line is too long
Plugins/OpenAPIGeneratorCommand/plugin.swift:62:1: warning: [LineLength] line is too long
** ERROR: ❌ Running swift-format produced errors.
To fix, run the following command:
% git ls-files -z '*.swift' | xargs -0 swift-format --in-place --parallel A few of the warnings were also pointing at non-existent (or wrong) lines (like EDIT: Not to mention the |
@simonjbeaumont @czechboy0 what should i do to resolve this last soundness error?
|
Had to exclude 2 to directories from read -ra PATHS_TO_CHECK_FOR_LICENSE <<< "$( \
git -C "${REPO_ROOT}" ls-files -z \
":(exclude).gitignore" \
":(exclude).spi.yml" \
":(exclude).swift-format" \
":(exclude).github/*" \
":(exclude)CODE_OF_CONDUCT.md" \
":(exclude)CONTRIBUTING.md" \
":(exclude)CONTRIBUTORS.txt" \
":(exclude)LICENSE.txt" \
":(exclude)NOTICE.txt" \
":(exclude)Package.swift" \
":(exclude)Package.resolved" \
":(exclude)README.md" \
":(exclude)SECURITY.md" \
":(exclude)scripts/unacceptable-language.txt" \
":(exclude)Tests/PetstoreConsumerTests/Generated" \
":(exclude)Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/*" \
":(exclude)docker/*" \
":(exclude)**/*.docc/*" \
":(exclude)**/.gitignore" \
":(exclude)**/Package.swift" \
":(exclude)**/Package.resolved" \
":(exclude)**/README.md" \
":(exclude)**/openapi.yaml" \
":(exclude)**/openapi.yml" \
":(exclude)**/petstore.yaml" \
":(exclude)**/openapi-generator-config.yaml" \
":(exclude)**/openapi-generator-config.yml" \
+ ":(exclude)Plugins/OpenAPIGenerator/PluginsShared" \
+ ":(exclude)Plugins/OpenAPIGeneratorCommand/PluginsShared" \
| xargs -0 \
)" |
Thanks @MahdiBM for bearing with us during this marathon of a PR 🙂 Just updated from main and will land once CI passes. |
Motivation
This PR adds the option to use the package as a Command plugin instead of a BuildTool plugin.
This benefits those who use heavy OpenAPI documents, and prefer not to have to wait for an extra round of OpenAPI code generation which can be accidentally triggered at times, for example if you clean your build folder.
The whole idea of creating this Command plugin came after @czechboy0 's comment here: #96 (comment)
Modifications
Generally, add a Command plugin target to the package, plus modifying the functions etc... to match/allow this addition.
Result
There is a new Command plugin, and users can choose between the Command plugin and the BuildTool plugin at will.
Test Plan
As visible in the PR discussions below, we've done enough manual-testing of the Command plugin.